function formatNumber(n) {
  n = n.toString()
  return n[1] ? n : '0' + n
}

function getToday() {
  var now = new Date();
  var year = now.getFullYear();
  var month = now.getMonth() + 1;
  var day = now.getDate();
  return [year, month, day].map(formatNumber).join('-');
}

function getTime() {
  var now = new Date();
  var hour = now.getHours(); 
  var minute = now.getMinutes(); 
  return [hour, minute].map(formatNumber).join(':');
}

function getFormatTime() {
  var now = new Date();
  var month = now.getMonth() + 1;
  var day = now.getDate();
  var hour = now.getHours();
  var minute = now.getMinutes();
  return [month, day].map(formatNumber).join('-') + ' ' + [hour, minute].map(formatNumber).join(':');
}

module.exports = {
  getToday: getToday,
  getTime: getTime,
  getFormatTime: getFormatTime
}
